from pprint import pprint

from authing.v2.authentication import AuthenticationClient, AuthenticationClientOptions
from authing.v2.management import ManagementClient, ManagementClientOptions

def manage():
    management_client = ManagementClient(
        options=ManagementClientOptions(
            user_pool_id='67af24dbbd1612cf26662afc',
            secret='dc56e5e4725c6b75948d47b3f15028eb',
        ))
    data = management_client.users.list()
    pprint(data)
def check_user():
    authentication_client = AuthenticationClient(
      options=AuthenticationClientOptions(
        app_id='67af24dcbd4f71f408805d14',
        app_host='https://kcbn0jxkvd5l-demo.authing.cn',
          token='eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6InI5Y1lJbTZXcGM2M2ZPQ285LVJpNi1mSV9tVldHMU1UbUpTOWZmbk9yRXMifQ.eyJzdWIiOiI2N2MxNTI2MzYxOGU5NGZiZWUzMjBkMmEiLCJhdWQiOiI2N2FmMjRkY2JkNGY3MWY0MDg4MDVkMTQiLCJpYXQiOjE3NDA3MjUxNjIsImV4cCI6MTc0MTkzNDc2MiwiaXNzIjoiaHR0cHM6Ly9rY2JuMGp4a3ZkNWwtZGVtby5hdXRoaW5nLmNuL29pZGMiLCJub25jZSI6IlBLNmVTaml4dm5sM1dFUEQ1NWl2IiwibmFtZSI6bnVsbCwiZ2l2ZW5fbmFtZSI6bnVsbCwibWlkZGxlX25hbWUiOm51bGwsImZhbWlseV9uYW1lIjpudWxsLCJuaWNrbmFtZSI6bnVsbCwicHJlZmVycmVkX3VzZXJuYW1lIjpudWxsLCJwcm9maWxlIjpudWxsLCJwaWN0dXJlIjoiaHR0cHM6Ly9maWxlcy5hdXRoaW5nLmNvL2F1dGhpbmctY29uc29sZS9kZWZhdWx0LXVzZXItYXZhdGFyLnBuZyIsIndlYnNpdGUiOm51bGwsImJpcnRoZGF0ZSI6bnVsbCwiZ2VuZGVyIjoiVSIsInpvbmVpbmZvIjpudWxsLCJsb2NhbGUiOm51bGwsInVwZGF0ZWRfYXQiOiIyMDI1LTAyLTI4VDA2OjQ1OjU5Ljg0M1oiLCJy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2VuZGVyIjoiVSIsInpvbmVpbmZvIjpudWxsLCJsb2NhbGUiOm51bGwsInVwZGF0ZWRfYXQiOiIyMDI1LTAyLTI4VDA2OjQ1OjU5Ljg0M1oiLCJyb2xlcyI6WyJhZG1pbiIsInVzZXIiXX0.r5CcsgfOeU-dUFQW2k4XS3dg4DcgSvqijZArLPie6AtnO2_VAPk7l-BnoRRINCYehZYZJTkSXxYn_cwa-nGXBfuk0j1PnYDbDhBbw1AF7zE6DX6xRbV6qbTk_pd_-QiKfdX25UAS-wAyxjYIZAAJ_KBM7IJDGvWQFaoVqUuadNjtzEhIkl437JEJsklFj1_Wr6mwP8OC8Syi95zH2hCmRJjCsX0Dj9rmji97wXrIIk_r56ge5gOS0HSVydqlupj4gxx1apkSr-IbT9dCurbv040t_BypIynUa9AtD_tepxfBWghWDAGBMxssNSyiuou1nFJ_CzQIMZH9CykQ_2S8SQ'
    # )
    # print(user)
    print(authentication_client.list_authorized_resources(
        # namespace='default'
        namespace='67af24dcbd4f71f408805d14'
    ))
    # print(authentication_client.list_applications(
    # ))
    print(authentication_client.list_roles(
        # namespace='default'
    ))
    print(authentication_client.check_logged_in(
        # namespace='default'
    ))
check_user()